package com.example.demo.properties;

import com.example.demo.util.YamlPropertyLoaderFactory;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 软件著作权:王艳明
 * 系统名称:SpringBoot后台管理系统
 *
 * @author WangYanming
 * @ClassName 类:ProjectProps.java
 * @Description 功能描述:project.yml
 * @Version 1.0
 * @date 2025-10-11 上午 11:46
 */
@Component
@ConfigurationProperties(prefix = "yml")
@PropertySource(value = "classpath:config/project.yml", encoding = "UTF-8", factory = YamlPropertyLoaderFactory.class)
@Data
public class ProjectProps {

    @Value("${yml.name}")
    private String name;

    @Value(value = "${yml.description}")
    private String description;

    @Value(value = "${yml.summary}")
    private String summary;

    //@Value(value = "${yml.fruits}")
    private List<String> fruits;

    private List<String> colors;

    @Value("${yml.project.name}")
    private String projectName;

    // @Value("${yml.project.dependencies}")
    // 此地方不能使用@Value注解,private Object project 时为null;
    // 可以使用map方式,也可以自定类Map<String, Object> project
    private Map<String, Object> project;

    @Value("${yml.server.ssl.certificate}")// 结果为cert.pem
    // @Value("${yml.server.ssl.certificate.cert}")获取不到值
    private String certificate;


}
